Skip to content

Conversation

@ymc9
Copy link
Member

@ymc9 ymc9 commented Aug 29, 2025

No description provided.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 29, 2025

📝 Walkthrough

Walkthrough

Added defensive null/undefined guards when iterating Prisma DMMF inputObjectTypes in multiple generators and bumped Prisma dependency version strings in an integration test from 6.14.x to 6.15.x. Changes are limited to guards, formatting, and string updates; no public API signatures changed.

Changes

Cohort / File(s) Summary
Integration test dependency versions
tests/integration/tests/cli/plugins.test.ts
Bump '@prisma/client' and 'prisma' from 6.14.x6.15.x in dependency arrays; only string literal changes.
OpenAPI RPC generator (guard + formatting)
packages/plugins/openapi/src/rpc-generator.ts
Use (this.dmmf.schema.inputObjectTypes.prisma ?? []) when pushing inputObjectTypes to avoid runtime errors if prisma is undefined; plus non-functional formatting changes.
Schema enhancer (guard + formatting)
packages/schema/src/plugins/enhancer/enhance/index.ts
Iterate over dmmf.schema.inputObjectTypes.prisma ?? [] in getLogicalDMMF to avoid undefined iteration; minor formatting/semicolon fixes elsewhere.
Zod generator (defensive guard)
packages/schema/src/plugins/zod/generator.ts
Construct inputObjectTypes from (prismaClientDmmf.schema.inputObjectTypes.prisma ?? []) to prevent runtime errors when missing; no other logic changes.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Gen as Generator
  participant DMMF as Prisma DMMF
  participant Proc as Processing Loop

  rect #E6F4EA
    Note right of Gen: Previously may access\ninputObjectTypes.prisma directly
    Gen->>DMMF: read schema.inputObjectTypes
    DMMF-->>Gen: possible undefined
  end

  rect #FFF4E6
    Note right of Proc: New guarded flow
    Gen->>Proc: iterate (schema.inputObjectTypes.prisma ?? [])
    Proc-->>Gen: zero or more inputObjectTypes
    Gen->>Gen: process each inputObjectType safely
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/prisma-6.15

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbit in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbit in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbit gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbit read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbit help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbit ignore or @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbit summary or @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbit or @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
tests/integration/tests/cli/plugins.test.ts (1)

72-82: No leftover @prisma/[email protected] references; optional DRY refactor
Search returned no matches for (@prisma/client|prisma)@6\.14\.. You may still define

const PRISMA_VER = '6.15.x';

(after reading ver) and update

- '@prisma/[email protected]',
+ `@prisma/client@${PRISMA_VER}`,

to centralize the Prisma version and prevent future drift.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 94a6dc2 and 898cc81.

⛔ Files ignored due to path filters (10)
  • packages/plugins/trpc/tests/projects/nuxt-trpc-v10/package.json is excluded by !**/*.json
  • packages/plugins/trpc/tests/projects/nuxt-trpc-v11/package.json is excluded by !**/*.json
  • packages/plugins/trpc/tests/projects/t3-trpc-v11/package.json is excluded by !**/*.json
  • packages/runtime/package.json is excluded by !**/*.json
  • packages/schema/package.json is excluded by !**/*.json
  • packages/sdk/package.json is excluded by !**/*.json
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml, !**/*.yaml
  • tests/integration/test-run/package.json is excluded by !**/*.json
  • tests/integration/tests/frameworks/nextjs/test-project/package.json is excluded by !**/*.json
  • tests/integration/tests/frameworks/trpc/test-project/package.json is excluded by !**/*.json
📒 Files selected for processing (1)
  • tests/integration/tests/cli/plugins.test.ts (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: build-test (20.x)
  • GitHub Check: dependency-review
  • GitHub Check: OSSAR-Scan
  • GitHub Check: build-test (20.x)
🔇 Additional comments (1)
tests/integration/tests/cli/plugins.test.ts (1)

85-94: Parametrize Prisma version and verify CI config
Apply within this hunk:

-            '[email protected]',
+            `prisma@${PRISMA_VER}`,

Manually confirm your CI workflows use Node.js ≥ 18 and that no [email protected] or @prisma/[email protected] pins remain.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/schema/src/plugins/zod/generator.ts (1)

92-97: Guard is right; avoid locale-sensitive lowercasing

The nullish coalescing is correct.However toLocaleLowerCase() on the exclude side vs toLowerCase() on the name side is inconsistent and can miscompare in certain locales (e.g., Turkish). Normalize with toLowerCase() on both.

-const inputObjectTypes = (prismaClientDmmf.schema.inputObjectTypes.prisma ?? []).filter(
-    (type) =>
-        !excludeModels.some((e) => type.name.toLowerCase().startsWith(e.toLocaleLowerCase())) &&
-        // exclude delegate aux related types
-        !type.name.toLowerCase().includes(DELEGATE_AUX_RELATION_PREFIX)
-);
+const inputObjectTypes = (prismaClientDmmf.schema.inputObjectTypes.prisma ?? []).filter(
+    (type) => {
+        const tn = type.name.toLowerCase();
+        return (
+            !excludeModels.some((e) => tn.startsWith(e.toLowerCase())) &&
+            // exclude delegate aux related types
+            !tn.includes(DELEGATE_AUX_RELATION_PREFIX)
+        );
+    }
+);
🧹 Nitpick comments (4)
packages/schema/src/plugins/enhancer/enhance/index.ts (1)

573-575: Use path.join for cross-OS safety

Hardcoded forward slashes can break on Windows. Prefer path.join to build internal file paths.

-const internalFilename = `${prismaClientDir}/internal/prismaNamespace.ts`;
-const internalFilenameFixed = `${prismaClientDir}/internal/prismaNamespace-fixed.ts`;
+const internalFilename = path.join(prismaClientDir, 'internal', 'prismaNamespace.ts');
+const internalFilenameFixed = path.join(prismaClientDir, 'internal', 'prismaNamespace-fixed.ts');
packages/plugins/openapi/src/rpc-generator.ts (3)

777-795: Typed-JSON model field mapping: good improvement; ensure consistent coverage

Enhancing generateField to resolve Json fields to TypeDef schemas via the ZModel is solid for entity schemas. Consider extending similar mapping to input object types to align with Zod generator behavior, so OpenAPI inputs also reference the specific TypeDef instead of generic JSON.


892-900: Dead branch: TypeDef detection for scalar Json never triggers here

Inside typeDefFieldTypeToOpenAPISchema, the JSON branch checks for a TypeDef named exactly 'Json'/'JSON', which won’t occur. Either drop the check or refactor input-type generation to pass contextual TypeDef info if you want typed-JSON for inputs as well.

-// For scalar types, reuse the existing mapping logic
-// Note: Json type is handled as empty schema for consistency
-return match(type.type)
-    .with('Json', () => ({} as OAPI.SchemaObject))
+// For scalar types, reuse the existing mapping logic
+// Json stays empty schema here; typed-JSON is handled elsewhere
+return match(type.type)
+    .with('Json', () => ({} as OAPI.SchemaObject))
     .otherwise((t) => {
         // Delegate to prismaTypeToOpenAPIType for all other scalar types
         return this.prismaTypeToOpenAPIType(String(t), false);
     });

925-933: Ineffective TypeDef probe for JSON; simplify

isTypeDefType will always be false because type is 'Json'|'JSON'. Simplify to always return {} here; keep typed-JSON handling in generateField (or refactor inputs as noted).

- .with(P.union('JSON', 'Json'), () => {
-     // For Json fields, check if there's a specific TypeDef reference
-     // Otherwise, return empty schema for arbitrary JSON
-     const isTypeDefType = this.model.declarations.some((d) => isTypeDef(d) && d.name === type);
-     return isTypeDefType ? this.ref(type, false) : {};
- })
+ .with(P.union('JSON', 'Json'), () => ({}))
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 898cc81 and c049bb3.

📒 Files selected for processing (3)
  • packages/plugins/openapi/src/rpc-generator.ts (6 hunks)
  • packages/schema/src/plugins/enhancer/enhance/index.ts (2 hunks)
  • packages/schema/src/plugins/zod/generator.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
packages/plugins/openapi/src/rpc-generator.ts (2)
packages/runtime/src/local-helpers/upper-case-first.ts (1)
  • upperCaseFirst (1-3)
packages/language/src/ast.ts (1)
  • DataModel (56-66)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: dependency-review
  • GitHub Check: build-test (20.x)
  • GitHub Check: build-test (20.x)
  • GitHub Check: OSSAR-Scan
  • GitHub Check: build-test (20.x)
🔇 Additional comments (4)
packages/schema/src/plugins/enhancer/enhance/index.ts (1)

482-498: Good defensive guard on DMMF input types iteration

Using (dmmf.schema.inputObjectTypes.prisma ?? []) prevents crashes when Prisma omits prisma input types. LGTM.

packages/plugins/openapi/src/rpc-generator.ts (3)

4-13: Import formatting changes are fine

Just layout/style adjustments. No functional impact.


60-62: Safe fallback for missing Prisma input types

...(this.dmmf.schema.inputObjectTypes.prisma ?? []) avoids runtime errors on 6.15 when prisma is absent. Good.


662-668: Adding AST-only enums to components is correct

Covers enums used only in TypeDefs. Looks good.

@ymc9 ymc9 merged commit e798397 into dev Aug 29, 2025
12 checks passed
@ymc9 ymc9 deleted the chore/prisma-6.15 branch August 29, 2025 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants